package com.atguigu.day02.tea;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;

/**
 * @Author : 孙峰
 * @Description:
 * @Date : 2022/7/2  9:07
 */
public class T2Task implements Callable<String> {
    private FutureTask<String> futureTask;

    public T2Task(FutureTask<String> futureTask) {
        this.futureTask = futureTask;
    }

    @Override
    public String call() throws Exception {
        System.out.println("T1:洗水壶...");
        TimeUnit.SECONDS.sleep(1);
        System.out.println("T1:烧开水...");
        TimeUnit.SECONDS.sleep(15); // 获取T2线程的茶叶
        String tf = futureTask.get();
        System.out.println("T1:拿到茶叶:" + tf);
        System.out.println("T1:泡茶...");
        return "上茶:" + tf;
    }
}
